package com.fast.fastenjoy.base.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.Session;
import org.hibernate.transform.ResultTransformer;

import com.fast.fastenjoy.base.domain.Page;

public interface BaseDao<T extends Serializable>{
	
	/**
	 * 保存实例
	 * @param entity
	 * @return
	 */
	public Serializable save(T entity);
	
	/**
	 * 批量保存实例
	 * @param entitys
	 */
	public void batchSave(List<T> entitys);
	
	public void update(T entity);
	
	public void batchUpdate(List<T> entitys);
	
	public void delete(T entity);
	
	public void batchDelete(List<T> entitys);
	
	public T get(Class<T> entityClass, Serializable id);
	
	public List<T> getAll(Class<T> entityClass);
	
	public List<T> getAll(Class<T> entityClass, String whereHql);
	
	public int executeBySql(String sql, Map<String, Object> paramMap);
	public Object findObjectBySql(String sql, Map<String, Object> paramMap, Class<?> entityClass);
	public Object findObjectBySql(String sql, Map<String, Object> paramMap, ResultTransformer resultTransformer);
	public List<?> findBySql(String sql, Map<String, Object> paramMap, Class<?> entityClass);
	public List<?> findBySql(String sql, Map<String, Object> paramMap, ResultTransformer resultTransformer);
	public Page findPageBySql(String sql, Map<String, Object> paramMap, Class<?> entityClass, Page page);
	public Page findPageBySql(String sql, Map<String, Object> paramMap, ResultTransformer resultTransformer, Page page);
	
	public int executeByHql(String hql, Map<String, Object> paramMap);
	public Object findObjectByHql(String hql, Map<String, Object> paramMap);
	public List<?> findByHql(String hql, Map<String, Object> paramMap);
	public Page findPageByHql(String hql, Map<String, Object> paramMap, Page page);
	
	public int executeBySqlId(String sqlId, Map<String, Object> paramMap);
	public Object findObjectBySqlId(String sqlId, Map<String, Object> paramMap);
	public List<?> findBySqlId(String sqlId, Map<String, Object> paramMap);
	public Page findPageBySqlId(String sqlId, Map<String, Object> paramMap, Page page);
	
	public BaseDao<T> flush(Session session);
	
	public BaseDao<T> clear(Session session);
	
}
